<template>
	<view class="content">
		<video :src="conttent.movie" controls :duration="info.time"></video>
		<!-- 弹窗 -->
		<view class="mask_bg" v-if="mask_show" @touchmove.stop.prevent>
			<view class="mask1">
				<view class="out">提示</view>
				<view class="out out1">请升级会员或者请充值积分</view>
				<view class="btn" @click="go()">确定</view>
				<view class="back" @tap="navigateBack()">返回</view>
			</view>
		</view>
	</view>
</template>

<script>
import getdata from '@/common/ajax.js';	
	export default {
		data() {
			return {
				conttent:'',
				info:'',
				mask_show: false,
			}
		},
		onLoad(option) {
			this.info = option
			//this.detail()
			// if(this.info.time){
			// 	getdata.shou('充值后可观看全部')
			// }
		},
		onShow(){
			this.userinfo()
		},
		methods: {
			userinfo(){
				//获取用户信息
				var _this = this
				var token = uni.getStorageSync('token')
				uni.request({
					url: getdata.websiteUrl + '/user/getUserInfo',
					header:{'content-type': "application/x-www-form-urlencoded",token:token},
					dataType: 'json',
					method: 'POST',
					success: res => {
						if(res.data.code == 1){
							_this.userInfo = res.data.data;
							if(_this.userInfo.can_view_video) {
								_this.detail()
							} else {
								_this.mask_show = true;
							}
						}else if(res.data.code == 401){
							getdata.shou('请登录')
							uni.reLaunch({
							    url: '../login/login'
							});
						}else{
							getdata.shou(res.data.msg)
						}
					},
					fail: res => {
						getdata.shou('服务器断开链接')
					}
				});
			},
			go(){
				uni.navigateTo({
				    url: '../../mine/vip/vip'
				});
			},
			navigateBack(){
				uni.navigateBack()
			},
			detail(){
				uni.showLoading({
				    title: '加载中'
				});
				//视频详情
				var _this = this
				var token = uni.getStorageSync('token')
				
				var data = {
					movie_id:_this.info.id,//视频ID
				}
				uni.request({
					url: getdata.websiteUrl + '/movie/detail',
					header:{'content-type': "application/x-www-form-urlencoded",token:token},
					dataType: 'json',
					method: 'POST',
					data:data,
					success: res => {
						uni.hideLoading();
						if(res.data.code == 1){
							_this.conttent = res.data.data
						}else{
							getdata.shou(res.data.msg)
						}
						
					},
					fail: res => {
						uni.hideLoading();
						getdata.shou('服务器断开链接')
					}
				});
			}
		}
	}
</script>

<style lang="scss">
.content{
	width: 100vw;
	height: 100vh;
	display: flex;
	justify-content: center;
	align-items: center;
	background: rgba(0,0,0,0.9);
	video{
		width: 100%;
		
	}
}
.mask_bg{
	z-index: 2;
	width: 100vw;
	height: 100vh;
	position: fixed;
	left:0;
	right:0;
	top:0;
	bottom:0;
	background: rgba(0, 0, 0, 0.2);
	display: flex;
	justify-content: center;
	align-items: center;
	.mask1{
		width: 624rpx;
		height: 400rpx;
		background: #FFFFFF;
		border-radius: 40rpx;
		.out{
			font-size: 24rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #333333;
			text-align: center;
			padding-top: 25rpx;
		}
		.out1{
			padding-top: 70rpx;
		}
		.btn{
			width: 300rpx;
			height: 90rpx;
			line-height: 90rpx;
			background: #1578F2;
			border-radius: 45rpx;
			font-size: 24rpx;
			font-family: PingFang SC;
			color: #FFFFFF;
			text-align: center;
			margin: 60rpx auto 0;
		}
		.back{
			width: 300rpx;
			height: 90rpx;
			line-height: 90rpx;
			background: #fff;
			border-radius: 45rpx;
			font-size: 24rpx;
			font-family: PingFang SC;
			color: #1578F2;
			text-align: center;
			margin: 0 auto ;
		}
	}
}
</style>
